-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Update MainApp.java #2405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Update MainApp.java #2405
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Decision: REQUEST_CHANGES — core requirements are missing and block task completion.
Critical issues to fix (blockers):
- Use abstract references as required: In
src/main/java/core/basesyntax/MainApp.java
, create aMachine[]
(or a collection ofMachine
) that holds instances ofTruck
,Bulldozer
, andExcavator
. This is mandated by the checklist and task. Why: The assignment requires demonstrating polymorphism via an abstract reference. - Implement the core loop in
main()
: Iterate over theMachine
array and calldoWork()
and thenstopWork()
on each element. Currently, only a placeholder print is present, so the program does not demonstrate the required behavior. - Formatting issues: Remove the redundant empty line after the class declaration and the empty line after the
main
method signature. This violates the checklist about avoiding redundant empty lines.
How to fix (hints):
- In
main(String[] args)
, instantiateMachine[] machines = new Machine[] { new Truck(), new Bulldozer(), new Excavator() };
then loop:for (Machine m : machines) { m.doWork(); m.stopWork(); }
. - Ensure
Truck
,Bulldozer
, andExcavator
extendMachine
, andMachine
declares abstract methodsdoWork()
andstopWork()
with informative messages in subclasses.
You’ve got the structure in place—once you wire up the Machine
hierarchy and the main loop, you’ll meet the core requirements. Keep going; you’re close!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review
button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor
tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
private MainApp() { | ||
} | ||
|
||
public static void main(String[] args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates checklist item: "Use abstract references instead of specific ones where possible" and the task requirement to instantiate an array (or collection) of Machine references containing Truck, Bulldozer, and Excavator instances. You must create such an array and use it in main().
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Java is the best"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates the core functional requirement: In main(), you must iterate over the Machine array and call doWork() and stopWork() on each element. Currently, you only print a placeholder message.
package core.basesyntax; | ||
|
||
public class MainApp { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates checklist item: "Please don't add redundant empty lines to your code." Remove the empty line after the class declaration.
|
||
private MainApp() { | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates checklist item: "Please don't add redundant empty lines to your code." Remove the empty line after the method signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Decision: Approve. The core functionality, inheritance structure, and polymorphic behavior are correctly implemented and meet the task requirements.
Reasoning: While there are typos in the stopWork()
messages across three classes, these are minor and do not break functionality. Still, they should be fixed to fully align with the checklist item about informative, correct English messages.
Issues to Address (non-blocking, but please fix):
- Typo in
stopWork()
messages:src/main/java/core/basesyntax/Bulldozer.java
– InstopWork()
, change "Bulldozer stoped working" to "Bulldozer stopped working". (Look near theSystem.out.println(...)
call, likely around the single print line in this method.)src/main/java/core/basesyntax/Excavator.java
– InstopWork()
, change "Excavator stoped working" to "Excavator stopped working".src/main/java/core/basesyntax/Truck.java
– InstopWork()
, change "Truck stoped working" to "Truck stopped working".
Why this matters: The checklist requires clear, correct English in user-facing messages. Correcting the spelling keeps your output professional and unambiguous.
Great job on the class hierarchy and the MainApp
polymorphism demo. Update the typos and you’ll be in perfect shape!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
} | ||
|
||
public void stopWork() { | ||
System.out.println("Bulldozer stoped working"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo in the output message: "Bulldozer stoped working" should be "Bulldozer stopped working". This violates checklist item: "Write informative messages in methods" (messages must be in correct English).
} | ||
|
||
public void stopWork() { | ||
System.out.println("Excavator stoped working"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo in the output message: "Excavator stoped working" should be "Excavator stopped working". This violates checklist item: "Write informative messages in methods" (messages must be in correct English).
} | ||
|
||
public void stopWork() { | ||
System.out.println("Truck stoped working"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo in the output message: "Truck stoped working" should be "Truck stopped working". This violates checklist item: "Write informative messages in methods" (messages must be in correct English).
No description provided.